//
//  BaseTableViewController.swift
//  MyWeiBo
//
//  Created by 张玉 on 15/9/13.
//  Copyright © 2015年 ZY. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController , VisitorLoginViewDelegate {

    
    /// 用户登录标记
    var userLogin = UserAccount.userLogon
//    var userLogin = false
    /// 访客视图
    var visitorView: VisitorUIView?
    override func loadView() {
          // 根据用户是否登录判断是否替换根视图
        userLogin ? super.loadView() : setupVisitorView()
        
    }
    
   /// 设置访客视图
    private func setupVisitorView() {
        visitorView = VisitorUIView()
        view = visitorView
        //成为代理
        visitorView?.delegate = self
        
         // 设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")

    }
    // MARK: - VisitorLoginViewDelegate

    func visitorLoginViewWillRegister() {
        print("注册")
            }

    func visitorLoginViewWillLogin() {
        
        //实例化 nav 根控制器为oauth
        let nav = UINavigationController(rootViewController: OauthViewController())
        //model 控制器
        presentViewController(nav, animated: true, completion: nil)

    }
}
